import sys
import http.client

def http_client(server,port=80,filename='/',showlines=6):
    server=http.client.HTTPConnection(server,port)
    server.putrequest('GET',filename)
    server.putheader('Accept','text/html')
    server.endheaders()
    reply=server.getresponse()
    if reply.status!=200:
        print('Error sending request!\n','status:',reply.status,'\n reason:',reply.reason)
    else:
        data=reply.readlines()
        reply.close()
        for line in data[:showlines]:print(line)

if __name__=='__main__':
    http_client('www.baidu.com')
